<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      /* 定位+margin:auto */
      /* .father {
        position: relative;
        width: 500px;
        height: 600px;
        border: 1px solid #0a3b98;
      }
      .son {
        position: absolute;
        width: 60px;
        height: 60px;
        background: #f0a238;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        margin: auto;
      } */

      /* 定位+margin-left/top 负值 */
      /* .father {
        position: relative;
        width: 400px;
        height: 400px;
        background: skyblue;
      }
      .son {
        position: absolute;
        top: 50%;
        left: 50%;
        margin-left: -50px;
        margin-top: -50px;
        width: 100px;
        height: 100px;
        background: red;
      } */

      /* 定位+tranform */
      /* 推荐 */
      /* .father {
        position: relative;
        width: 400px;
        height: 400px;
        background: skyblue;
      }
      .son {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 100px;
        height: 100px;
        background: red;
      } */

      /* table-cell 布局 */
      /* .father {
        display: table-cell;
        vertical-align: middle;
        text-align: center;
        width: 200px;
        height: 200px;
        background: skyblue;
      }
      .son {
        display: inline-block;
        width: 50px;
        height: 100px;
        background: red;
      } */

      /* 弹性盒子 */
      /* 推荐 */
      /* .father {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 400px;
        height: 400px;
        background: skyblue;
      }
      .son {
        width: 100px;
        height: 100px;
        background: red;
      } */

      /* grid 布局  */
      /* 兼容性较差 */
      /* .father {
        display: grid;
        align-items:center;
        justify-content: center;
        width: 400px;
        height: 400px;
        background: skyblue;
      }
      .son {
        width: 50px;
        height: 50px;
        background: red;
      } */
    </style>
  </head>
  <body>
    <div class="father">
      <div class="son">aa</div>
      <div class="son">bb</div>
    </div>
  </body>
</html>
